package com.hhh.petadopt.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.hhh.petadopt.pojo.News;
import com.hhh.petadopt.service.SeachService;

/**
 * 搜索
 * @author 杜镇声声
 *
 */
@Controller
public class SearchController {
	@Autowired
	private SeachService seachService;
	
	@RequestMapping(value="/search/searchNews")
	public String searchPage(String word,Model model) {
		
		List<News> newsListt = null;
		String flag = "1";
		//查询符合条件的总条数
		Integer count = seachService.selectNewsCountByWords(word);
		//查询符合条件的新闻列表
		newsListt = seachService.selectNewsByWord(word);
		
		
		//将数据保存到模型中
		model.addAttribute("word", word);
		model.addAttribute("count", count);
		model.addAttribute("newsListt", newsListt);
		model.addAttribute("flag", flag);
		
		return "newsList";
	}

}
